<?php
include dirname(__FILE__).'/PHPExcel/IOFactory.php';

class ReadExcel
{
	public $colls;
	public $objPHPExcel;
	
	public function load($inputFile = '', $sheet = 0)
	{
		if(!is_file($inputFile)) return false;
		$objReader = new PHPExcel_Reader_Excel5();
		$this->objPHPExcel = $objReader->load($inputFile);
		$this->colls = array();
		$loadedSheetNames = $this->objPHPExcel->getSheetNames();
		$firstSheetName = $loadedSheetNames[$sheet];
		$sheetData = $this->objPHPExcel->getActiveSheet()->toArray(null,false,false,true);
		foreach($sheetData as $index=>$colls)
		{
			foreach($colls as $coll=>$row) $this->colls[$coll][$index] = $row;
		}
		return $this->colls;
	}
	
	public function search_colls($key)
	{
		$data = array();
		foreach($this->colls as $col=>$arr)
		{
			$find = false;
			foreach($arr as $i=>$val)
			{
				if($find == true) $data[] = $val;
				if($val == $key)
				{
					$find = true;
					continue;
				}
			}
		}
		return $data;
	}
}
